<template>
  <el-tooltip effect="dark" :content="text" placement="top" :disabled="disabled">
    <span class="icon-button" :class="{ 'is-disabled': disabled }" :style="{ color: textColor }" @click="onClick">
      <i :class="icon"></i>
    </span>
  </el-tooltip>
</template>

<script>
export default {
  name: 'base-icon-button',
  props: {
    text: {
      type: String,
      default: '',
    },
    textColor: {
      type: String,
      default: '',
    },
    icon: {
      type: String,
      required: true,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    onClick() {
      if (this.disabled) return;
      this.$emit('click');
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../../assets/scss/design/colors";

.icon-button {
  padding: 0 6px;
  cursor: pointer;

  &:not(.is-disabled) {
    color: $color-text-primary;

    &:hover {
      color: $color-text-primary-hover;
    }
  }

  &.is-disabled {
    color: #ddd;
    cursor: not-allowed;
  }
}
</style>
